/**
 * @param {number} start
 * @param {number} finish
 * @param {number} limit
 * @param {string} s
 * 线判断s师傅符合每一位小于limit
 * 在s前按照limit添加前缀，跟start和finish差值/10*limit
 * 又超时，好烦
 * 
 * 偷懒思路，找最大值和最小值，中间
 * @return {number}
 */
var numberOfPowerfulInt = function(start, finish, limit, s) {
    const resultList = []
    if (Math.max(...s) > limit ||  Number(s) > finish) return 0
    for (let i = 0, count = Number(s), j = limit;count <= finish ;) {
        // if (count >= start)  resultList.push(count)
        if (Math.max(...String(i)) <= limit && count >= start) {
            resultList.push(count)
        }
        i  += 1
        count = i * Math.pow(10, s.length) + Number(s)
        console.log(count, i)
    }
    console.log(resultList)
    return resultList.length
};


const start = 1, finish = 2000, limit = 8, s = "1"
console.log(numberOfPowerfulInt(start, finish, limit, s))